<!--
 * @Author: daidai
 * @Date: 2022-03-01 15:51:43
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-09-29 15:12:46
 * @FilePath: \web-pc\src\pages\big-screen\view\indexs\right-bottom.vue
-->
<template>
  <!-- <div class="right_bottom">
    <dv-capsule-chart :config="config" style="width:100%;height:260px" />
  </div> -->
  <div class="container">
    <div class="list" ref="list">
      <a class="item" v-for="item in list" href="https://www.baidu.com" target="__blank">
        <div class="item-title">
          {{ item.title }}
        </div>
        <div class="date">{{ item.date }}</div>
      </a>
    </div>
  </div>
</template>

<script>
import { currentGET } from "api/modules"
export default {
  data() {
    return {
      list: new Array(20).fill({}).map((_, i) => ({
        title: "2023年塔里木大学实验室安全检查的通知" + i,
        date: "2023-01-02",
      })),
      index: 0,
      timer: null,
      isEnd: false,
    }
  },
  created() {
    this.getData()
  },
  computed: {},
  mounted() {
    console.log("refs", this.$refs)
    this.timer = setInterval(this.animate, 1500)
    document.onvisibilitychange = () => {
      if (document.visibilityState == "visible") {
        this.timer = setInterval(this.animate, 1500)
      } else {
        clearInterval(this.timer)
      }
    }
  },
  beforeDestroy() {
    this.clearData()
  },
  methods: {
    animate() {
      if (this.isEnd) {
        this.index--
        if (this.index == 0) {
          this.isEnd = false
        } else {
          this.$refs.list.style.transform = `translateY(-${40 * this.index}px)`
        }
      } else {
        this.index++
        if (this.index + 5 == this.list.length) {
          this.isEnd = true
        } else {
          this.$refs.list.style.transform = `translateY(-${40 * this.index}px)`
        }
      }
    },
    clearData() {
      if (this.timer) {
        clearInterval(this.timer)
        this.timer = null
      }
    },
    //轮询
    switper() {
      if (this.timer) {
        return
      }
      let looper = a => {
        this.getData()
      }
      this.timer = setInterval(looper, this.$store.state.setting.echartsAutoTime)
    },
    getData() {
      this.pageflag = true
      // this.pageflag =false
      currentGET("big7", { gatewayno: this.gatewayno }).then(res => {
        if (!this.timer) {
          console.log("报警排名", res)
        }
        if (res.success) {
          this.config = {
            ...this.config,
            data: res.data,
          }
          this.switper()
        } else {
          this.pageflag = false
          this.srcList = []
          this.$Message({
            text: res.msg,
            type: "warning",
          })
        }
      })
    },
  },
}
</script>
<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  .list {
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
    &::-webkit-scrollbar,
    &::-webkit-scrollbar-track-piece {
      background-color: transparent;
    }

    &::-webkit-scrollbar-thumb {
      border-radius: 3px;
      background-color: #5dc0ff;
    }

    &::-webkit-scrollbar {
      width: 7px;
      height: 6px;
    }
    .item {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      padding: 0 10px 0 10px;
      gap: 10px;
      cursor: pointer;
      height: 40px;
      .item-title {
        flex: 1;
        color: #5dc0ff;
        font-size: 16px;
        font-weight: bold;
        white-space: nowrap; /* 禁用换行 */
        overflow: hidden; /* 溢出部分隐藏 */
        text-overflow: ellipsis; /* 显示省略号 */
      }
      .date {
        width: 100px;
        color: #52a9e4;
        font-size: 16px;
      }
    }
  }
}
.list_Wrap {
  height: 100%;
  overflow: hidden;
  :deep(.kong) {
    width: auto;
  }
}

.sbtxSwiperclass {
  .img_wrap {
    overflow-x: auto;
  }
}

.right_bottom {
  box-sizing: border-box;
  padding: 0 16px;

  .searchform {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;

    .searchform_item {
      display: flex;
      justify-content: center;
      align-items: center;

      label {
        margin-right: 10px;
        color: rgba(255, 255, 255, 0.8);
      }

      button {
        margin-left: 30px;
      }

      input {
      }
    }
  }

  .img_wrap {
    display: flex;
    // justify-content: space-around;
    box-sizing: border-box;
    padding: 0 0 20px;
    // overflow-x: auto;

    li {
      width: 105px;
      height: 137px;
      border-radius: 6px;
      overflow: hidden;
      cursor: pointer;
      // background: #84ccc9;
      // border: 1px solid #ffffff;
      overflow: hidden;
      flex-shrink: 0;
      margin: 0 10px;

      img {
        flex-shrink: 0;
      }
    }
  }

  .noData {
    width: 100%;
    line-height: 100px;
    text-align: center;
    color: rgb(129, 128, 128);
  }
}
</style>
